package com.hq.fxh.No3_TuiGuang.Adaoter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hq.fxh.Modle.GetPushStatisticListResDay;
import com.hq.fxh.R;

import java.util.List;



/**
 * @author 小谢
 * @ClassName PushStatisticItemAdapter
 * @Description :
 * @Created 2017/5/18 0018
 */

public class PushStatisticItemAdapter extends RecyclerView.Adapter<PushStatisticItemAdapter.ViewHolder>{
    private List<GetPushStatisticListResDay> list;

    public PushStatisticItemAdapter(List<GetPushStatisticListResDay> list) {
        this.list = list;
    }
    @Override
    public PushStatisticItemAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int i) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_item, parent, false);
        ViewHolder vh = new ViewHolder(view);
        return vh;
    }

    @Override
    public void onBindViewHolder(PushStatisticItemAdapter.ViewHolder holder, int position) {
        String date[] =list.get(position).getDate().split("-");
        holder.tv_data_info.setText(date[1] +"月" +date[2]+"日");//"date": "2017-05-15"
        holder.tv_click.setText("点击"+list.get(position).getClick());
        holder.tv_look.setText("曝光"+list.get(position).getLook());
    }

    @Override
    public int getItemCount() {
        return list.isEmpty() ? 0 : list.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView tv_data_info,tv_click,tv_look;

        public ViewHolder(View itemView) {
            super(itemView);
            tv_data_info=(TextView)itemView.findViewById(R.id.tv_data_info);
            tv_click=(TextView)itemView.findViewById(R.id.tv_click);
            tv_look=(TextView)itemView.findViewById(R.id.tv_look);
        }
    }
}
